{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.6.10"
    },
    "colab": {
      "name": "Google Colab Setup.ipynb",
      "provenance": [],
      "collapsed_sections": [],
      "toc_visible": true
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "KAO8D7VEmNTD",
        "colab_type": "text"
      },
      "source": [
        "## To set up the directory in your Google Drive, \n",
        "\n",
        "First upload ML_Finance_Codes.zip into the working directory using the Files panel of the sidebar on the left.\n",
        "\n",
        "Once it has uploaded, it should appear alongside sample_data. \n",
        "\n",
        "Then, run the cell below to unzip it into your Google Drive. Allow time for the unzipping to complete."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "h6IE_PFWD_k1",
        "colab_type": "code",
        "outputId": "030c2b52-9647-44b4-f3bf-22d624976e30",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        }
      },
      "source": [
        "from google.colab import drive\n",
        "import os    \n",
        "mountpoint = '/content/drive'\n",
        "drive.mount(mountpoint, force_remount=True)\n",
        "path = mountpoint + '/My Drive/'\n",
        "unzip_cmd = 'unzip ML_Finance_Codes.zip -d ' + path.replace(' ', '\\ ')\n",
        "\n",
        "if os.path.exists('ML_Finance_Codes.zip'):\n",
        "    if os.path.exists(dir_path):\n",
        "        print(dir_path, 'exists already.')\n",
        "    else:\n",
        "        os.system(unzip_cmd)\n",
        "else:\n",
        "    print('ML_Finance_Codes.zip not in current working directory!')"
      ],
      "execution_count": 54,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Mounted at /content/drive\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "56kZoOqemNTT",
        "colab_type": "text"
      },
      "source": [
        "## Once ML_Finance_Codes directory is in Google Drive, \n",
        "add this cell to the top of a notebook, \n",
        "set nb_folder to the correct folder name, \n",
        "and run the cell before running the rest of the notebook"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "sQuJupS9mNTi",
        "colab_type": "code",
        "outputId": "d332d9d5-041c-48cc-f91c-a55c0efe9ff1",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 52
        }
      },
      "source": [
        "nb_folder = \"Chapter4-NNs/\" # This should match the name of the folder within ML_Finance_Codes\n",
        "                            # in which the notebook that you are running originates\n",
        "try:    \n",
        "    from google.colab import drive\n",
        "    on_colab = True\n",
        "except ModuleNotFoundError:\n",
        "    on_colab = False\n",
        "    print(\"Assuming you are running this notebook from the 'MLFenv'\")\n",
        "    print(\"virtual environment described in SETUP.html\")\n",
        "\n",
        "if on_colab:\n",
        "    import os    \n",
        "    mountpoint = '/content/drive'\n",
        "    drive.mount(mountpoint, force_remount=True)\n",
        "    path = mountpoint + '/My Drive/ML_Finance_Codes/' + nb_folder\n",
        "    try:\n",
        "        os.chdir(path)\n",
        "        print('Current working directory:', os.getcwd())\n",
        "    except FileNotFoundError as e:\n",
        "        print(\"\\nThe 'ML_Finance_Codes' folder must be unzipped in\")\n",
        "        print(\"the root directory of your Google Drive!\\n\")\n",
        "        print(e)"
      ],
      "execution_count": 59,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Mounted at /content/drive\n",
            "Current working directory: /content/drive/My Drive/ML_Finance_Codes/Chapter4-NNs\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "65UqdDu6ZdWq",
        "colab_type": "text"
      },
      "source": [
        "If a notebook requires either of these libraries, run the corresponding command below to install it in the Google Colab VM:"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "y778ACtmmNTu",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "!pip install gpytorch"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "GXSiZsWGSiAE",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "!pip install arviz"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "z3KkYXIWmNUD",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        ""
      ],
      "execution_count": 0,
      "outputs": []
    }
  ]
}